package com.qf.blog.commons.pool;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程池
 *
 * @author Zhendong Song
 * @time 2023/6/10 16:25
 **/
public class BlogExecutors {

    private static ThreadPoolExecutor executors = null;

    static {
        executors = new ThreadPoolExecutor(10, // 核心线程池数量，初始化时线程池中的数量
                30, // 最大的线程池数量
                30, // 时间
                TimeUnit.SECONDS, // 时间单位
                new ArrayBlockingQueue<>(500), // 队列的长度
                Executors.defaultThreadFactory(), // 线程工厂
                new ThreadPoolExecutor.DiscardPolicy()); // 拒绝策略
    }

    public static ThreadPoolExecutor getPoll() {
        return executors;
    }
}
